using HMCollada.Core;
using HMCollada.FX;
using System.Xml;

namespace HMCollada.FX {
    internal struct HMColladaMaterial {
        internal string id;
        internal string name;
        internal HMColladaAsset asset;
        internal HMColladaInstanceEffect instance_effect;
    }
}

namespace HMCollada {
    internal partial class HMColladaLoader {
        private static HMColladaMaterial LoadMaterial() {
            HMColladaMaterial newMaterial = new HMColladaMaterial();
            newMaterial.id = colladaReader.GetAttribute("id");
            newMaterial.name = colladaReader.GetAttribute("name");

            if (!colladaReader.IsEmptyElement) colladaReader.Read();
            do {
                if (colladaReader.NodeType != XmlNodeType.EndElement) {
                    switch (colladaReader.Name) {
                        case "asset": newMaterial.asset = LoadAsset(); break;
                        case "instance_effect": newMaterial.instance_effect = LoadInstanceEffect(); break;
                    }
                }

                if (!colladaReader.IsEmptyElement) colladaReader.Read();
            } while (colladaReader.Name != "material");

            if (colladaReader.IsEmptyElement) colladaReader.Read();
            return newMaterial;
        }
    }
}